package org.tank;

import java.awt.*;

/**
 * 子弹
 */
public class Explode {
  public   int x=400;
  public   int y=400;
 public    int width,height=50;
    //子弹的移动速度
    public static  final int  speed=200;

    TankFram2 tankFram2=null;

    //是否还在存活
    public boolean isLive=true;

    private int step=0;

    public Explode(int x, int y, int width, int height, TankFram2  tankFram2,boolean isLive) {
        this.x = x;
        this.y = y;
        this.width=width;
        this.height=height;
        this.tankFram2=tankFram2;
        this.isLive=isLive;
    }

    public Explode(){}

    public void fillRect(Graphics g) {
          if(step>=15) {
              step=0;
              isLive=false;
          }
        //  g.fillOval(x,y,40,40);
          g.drawImage(TankImage.explode[++step],this.x,this.y,null);
    }

    public void setMove(boolean isLeft,boolean isRight,boolean isUp,boolean isDown) {
            if(isLeft) x-=speed;
            if(isRight) x+=speed;
            if(isUp) y-=speed;
            if(isDown) y+=speed;
        if(x < 0 || y < 0 || x > tankFram2.GAME_WIDTH || y > tankFram2.GAME_HEIGHT) isLive = false;
    }
}
